/*************************************************
 *FileName:      wlecome.js
 *Description:   欢迎回来.js
 *Others:        陈灿
 *************************************************/
    /*
     * 启动
     */
    var wlecomeopen = false;
    mui.plusReady(function(){ 
        var wv=plus.webview.currentWebview();// 关闭侧滑返回功能
        wv.setStyle({'popGesture':'none'});
        var old_back = mui.back;
        mui.back = function() {
            if(wlecomeopen==true){
                old_back();
                wlecomeopen=false;
            }else{
                
            }
        }
    });
    /*
     * 变量初始化
     */
    
    /*
     * 主程序
     */ 
    $(document).ready(function() 
    {
        //样式加载
        pagecss();
    });
    /**
     * pagecss
     * 样式加载
     * @cc 
     * @DateTime 2018-01-08T06:19:16+0800
     * @param    int        
     * @return   void
     */

    var uid = '';
    var token = '';
    var hoder_pass = '';

    if(localStorage.replace_uid){
        uid = localStorage.replace_uid;
    }
    if(localStorage.replace_token){
        token = localStorage.replace_token;
    }

    function pagecss(){
        
        if(!localStorage.replace_token || !localStorage.replace_uid){
            common.pageTransition("login.html");
        }
        $('.alink').on('tap',function(){
            common.pageTransition("forgetpsd.html");
        })
        
        $('.phone').html(localStorage.replace_nickname)
        $('.userimg').attr('src',DOMAIN_NAME+localStorage.replace_face)
        
        $('.close').on('tap',function(){
            plus.runtime.quit(); //关闭应用
        })
    }

    (function($, doc,$$) {
        $.init();
        var holder = doc.querySelector('#holder'),
            alert = doc.querySelector('#alert'),
            record = [];
        //处理事件
        holder.addEventListener('done', function(event) {
            var rs = event.detail;
            if(doc.querySelector('.ResetGestureCode1') !=null ){
                var gestures_password = rs.points.join('');
//              mui.toast('密码验证中...',{ duration:2000, type:'div' });
                $$.ajax({
                    type: "post",
                    url: DOMAIN_NAME + "/index.php/api/user/turesPasswordCheck",
                    dataType:'jsonp',
                    data: { uid: uid, token: token, gestures_password: gestures_password},
                    success: function(data) {
                        if(data.error_code == 0){
//                          mui.toast('密码正确');
                            record = [];
                            rs.sender.clear();
                            localStorage.welcome='false';
                            wlecomeopen=true;
                            mui.back();
                            var list = plus.webview.currentWebview().opener();//触发父页面的自定义事件(refresh),从而进行刷新
                            mui.fire(list, 'refreshindex');//返回true,继续页面关闭逻辑
                            return true;
                        }else if(data.error_code == 1001){
                            setTimeout(function(){
                                exitlogin();
                            },1000);
                        }else{
//                          mui.toast('密码错误');
                            record = [];
                            rs.sender.clear();
                            if(data.ad.url){
                                plus.runtime.openURL(data.ad.url);
                            }
                            return;
                        }
                        
                    }
                })
            }else{
                if (rs.points.length < 4) {
                    rcode2text.text('设定的手势太简单了').addClass('color');
                    record = [];
                    rs.sender.clear();
                    return;
                }
                record.push(rs.points.join(''));
                if (record.length >= 2) {
                    if (record[0] == record[1]) {
                        rcode2text.text('手势设定完成');
                        window.location="index.html";
                    } else {
                        rcode2text.text('两次设置不一样，请重新设置').addClass('color');
                    }
                    rs.sender.clear();
                    record = [];
                }else{
                    rcode2text.text('请确认手势设定').removeClass('color');
                    rs.sender.clear();
                }
            }
        });
    }(mui, document,jQuery));

    /**
     * adds //方法名
     * @陈灿 //作者名
     * @DateTime 2018-01-010T0116:25:00+0800 //时间
     * @param    int    $goods_id //参数
     * @param    array  $data //参数
     * @return    array  [error_code, error_msg, goods_id] //返回值
     */
